﻿﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="<s:url value="/assets/web/css/base.css"></s:url>">
    <link rel="stylesheet" href="<s:url value="/assets/web/css/login/bootstrap.min.css?v=3.3.6"></s:url>">
    <!-- 基本框css -->
    <link rel="stylesheet" href="<s:url value="/assets/web/css/base_nav.css"></s:url>">
    <!-- 项目管理Css -->
    <link rel="stylesheet" href="<s:url value="/assets/web/css/user/user_xmProject.css"></s:url>">
    <title>审核节点列表</title>
    <style>
        .node-names:after{
            clear: both;
            content: "";
            display: block;
        }
        .node-names{
            position: relative;
        }
        .node-names a{
          float: right;
        }
        .node-names p{
            float: left;
        }
    </style>
</head>

<body class="bgcolor">
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>
<table></table>
<div id="content-main" class="av row J_mainContent">
    <div class="user-project-manger">
        <div class="container" style="position: relative;">
            <%--<div class="search-project">
                <input type="text" id="search-input">
                <button class="search-btn">搜索</button>
            </div>
            <ul class="project-btn">
                <li class="primary" id="allProject">全部项目</li>
                <li class="pending" id="pass">已审核项目</li>
                <li class="finished-task" id="noPass">未审核项目</li>
                <li id="status" style="display: none;"></li>
                <li id="pages" style="display: none;"></li>
            </ul>--%>
        </div>
        <div class="container">
            <table class="project-info">
                <thead>
                <tr>
                    <th>项目名称</th>
                    <th>节点名称</th>
                    <th>状态</th>
                    <th>开始时间</th>
                    <th>计划数（天）</th>
                    <th>操作</th>

                </tr>
                </thead>
                <tbody id="index-main">
                </tbody>
            </table>
        </div>
        <!-- 分页 -->
        <div class="footer">
            <ul class="pagination" id="pagination0"></ul>
        </div>

    </div>

</div>
<%--修改模态框--%>
<div class="modal fade" id="myModal-update" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <p class="node-title" style="display: inline-block;font-size: 20px;font-weight: bold; margin: 0;"></p>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <%--<div class="module-node-name">
                    <p></p>
                    <p></p>
                    <p></p>
                </div>--%>
            </div>
            <form action="">
                <div class="modal-body">
                    <div class="node-names-content" id="node-names-content">

                    </div>
                    <div class="node-status">
                        节点状态：
                        <select name="" id="node-status">
                            <option value="1">通过</option>
                            <option value="0">退回修改</option>
                        </select>
                    </div>
                    <div class="node-status"  id="denyReasons">
                        <div style="font-weight:bold; margin-top: 15px; margin-bottom: 5px; font-size: 18px;">退回修改理由：</div>
                        <div>
                            <textarea name="denyReason" id="denyReason"   rows="5" style="resize:none; width: 100%;"></textarea>
                        </div>
                    </div>
                </div>
                 <input type="hidden"  id="sysId"/>
                <input class="project-id" hidden name="" type="text">
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="sub">提交</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</div>


<script src="<s:url value="/assets/web/js/jquery.min.js?v=2.1.4"></s:url>"></script>
<script src="<s:url value="/assets/web/js/bootstrap.min.js"></s:url>"></script>
<script src="<s:url value="/assets/web/js/jqpaginator.min.js"></s:url>"></script>

<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"
<%--项目管理js--%>
<script src="<s:url value="/assets/web/js/user/user_xmProject.js"></s:url>"></script>
<script>
    $(function () {
        //分页
        $('#pagination0').jqPaginator({
            totalPages: ${totalPage},
            visiblePages: 5,
            currentPage: 1,
            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (num) {
                $('#text').html('当前第' + num + '页');
                $.ajax({
                    type: "POST",
                    url: "/accAudit/go/lists",
                    dataType: "json",
                    data: {page: num - 1},
                    success: function (data) {
                        var html = "";
                        for (var i = 0; i < data.list.length; i++) {
                            var list = data.list[i];
                            html += '\
                                 <tr>\
                        <td style="display: none">' + list.sysId + '</td>\
                        <td>' + list.projectsName+'</td>\
                        <td>' + (list.nodeId )+ ' '+(list.nodeName)+'</td>\
                        <td>' + (list.status == 1 ? "未审核" : list.status == 2 ? "审核通过" : list.status == 3 ? "项目已完成" : "未确定") + '</td>\
                        <td>' + (list.planBeginDate)+ '</td>\
                        <td>' + (list.planTime) + '</td>\
                        <td><button class="update-button" data-id="' + list.sysId + '" data-nodename="' + list.nodeId + list.nodeName + '"  data-toggle="modal" data-target="#myModal-update">审核</button></td>\
                        </tr>';
                        }
                        $("#index-main").html(html);
                    },
                    error: function () {
                        console.log("发生错误");
                    }
                });
            }
        });


        // 修改
        $("#index-main").on("click", ".update-button", function () {
            var sysId = $(this).data("id"); //项目id
            var nodeName = $(this).data("nodename"); //项目名称
            var postdata={
                "sysId":sysId
            };
            $.ajax({
                type: "post",
                url:"/accAudit/getNodeNewschedulesById",
                dataType: "json",
                data: JSON.stringify(postdata),
                contentType: 'application/json;charset=utf-8',
                success: function (res) {
                    if(res.list.length!=0) {
                        var html="";
                        for (var i = 0; i < res.list.length; i++) {
                            var list = res.list[i];
                            if(list.nodeFilter !=""){
                                html+='\
                                 <div class="node-names">\
                                  <p>'+list.nodeId+''+list.nodeName+'</p>\
                                  <a  class="update-btns" href="/upLoad/downloadProjectFile/'+list.sysId+'.zip">下载</a>\
                               </div>';
                            }else{
                                html+='\
                                  <div class="node-names">\
                                  <p>'+list.nodeId+''+list.nodeName+'</p>\
                                  <a  class="update-btns" href="javascript:void(0);">暂无可下载文件</a>\
                               </div>';
                            }

                        }
                        $("#node-names-content").html(html)
                        $(".node-title").html(nodeName+"--审核操作");
                    }
                    $("#sysId").val(sysId);
                },
                error: function (res) {

                }
            })

        });

        $("#sub").click(function () {
            var sysId = $("#sysId").val();
            var status = $("#node-status").val();
            var denyReason = $("#denyReason").val();
            var postdata = {
                "sysId": sysId,
                "status": status,
                "denyReason": denyReason
            };

            $.ajax({
                type: "post",
                url: "/accAudit/jointProcessing",
                dataType: "json",
                data: JSON.stringify(postdata),
                contentType: 'application/json;charset=utf-8',
                success: function (res) {
                    if (res.code == '200') {
                        alert("更新成功");
                        location.reload();
                    } else if (res.code == '500') {
                        alert("更新失败," + res.msg);
                    }

                },
                error: function (res) {

                }
            })
            console.log(postdata);

        });

        //全部项目点击事件
        $("#allProject").click(function () {
            window.location.reload();
        })
    })


    <%--确认通过不的显示或隐藏--%>
    $("#index-main").on("click", ".through", function () {

        var a = $(this).parent().prev().prev().html();
        $(".through-or-no-2").hide();
        $(".through-or-no-1").show();
        var lid = $(this).data("sysid"); //用户名
        $("#passY>form>input").val(lid);
    });

    $("#index-main").on("click", ".no-through", function () {
        $(".through-or-no-2").show();
        $(".through-or-no-1").hide();
        var lid = $(this).data("sysid"); //用户名
        $("#passN>form>input").val(lid);
    });
    /* function yshow(){
        $("#denyReason").show();
    }
   function yhide(){
        $("#denyReason").hide();
   }*/
</script>
</body>

</html>